package com.blb.community.controller;

import com.blb.community.Annotation.Log;
import com.blb.community.entity.ZyOwnerRoom;
import com.blb.community.service.IZyOwnerRoomService;
import com.blb.community.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 房屋绑定表  前端控制器
 * </p>
 *
 * @author 帅帅
 * @since 2022-07-02
 */
@RestController
@RequestMapping("/zy-owner-room")
@CrossOrigin
@Api(tags = "房屋绑定")
public class ZyOwnerRoomController {

    @Autowired
    private IZyOwnerRoomService iZyOwnerRoomService;
    @Log(module = "修改", operationType = 2, requestMethod = "PUT")
    @PutMapping("/update/{id}")
    public ResponseResult<String> updateStatusOwner(@PathVariable String id){
        iZyOwnerRoomService.updateStatusOwner(id);
        return ResponseResult.ok("更新成功");
    }
    @Log(module = "小区互动删除", operationType = 3, requestMethod = "DELETE")
    @ApiOperation("小区互动删除")
    @DeleteMapping("/interaction/{id}")
    public ResponseResult<String> delOwner(@PathVariable Long id){
        iZyOwnerRoomService.removeById(id);
        return ResponseResult.ok("删除成功");
    }
    @Log(module = "业主房屋绑定", operationType =1, requestMethod = "POST")
    @ApiOperation("业主房屋绑定")
    @PostMapping("")
    public ResponseResult<String> addOwnerRoom(@RequestBody ZyOwnerRoom zyOwnerRoom) {
        boolean save = iZyOwnerRoomService.save(zyOwnerRoom);
        if (save) {
            return ResponseResult.ok("添加成功");
        }
        return ResponseResult.error("添加失败");
    }
}
